package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.joda.time.LocalDate;

import cn.seqdata.jpa.AbstractPersistable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "customer_risk")
public class CustomerRisk extends AbstractPersistable<CustomerRiskId> {
	private static final long serialVersionUID = 1L;

	private Customer customer;
	private RiskType risk;
	private Integer score;

	public CustomerRisk() {
	}

	public CustomerRisk(LocalDate date, long customer, int risk) {
		setId(new CustomerRiskId(date, customer, risk));
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customer", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "risk", nullable = false, insertable = false, updatable = false)
	@JsonSerialize(using = cn.seqdata.jackson.TypeSerializer.IdName.class)
	public RiskType getRisk() {
		return this.risk;
	}

	public void setRisk(RiskType risk) {
		this.risk = risk;
	}

	@Column(name = "score")
	public Integer getScore() {
		return this.score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}
}